/**
 * This is the StoreController Class
 * This class handles operations that take place in the store
 * @author Chris Adams
 * @version 1.0 10/20/2011
 */

public class StoreController {
	
	private WagonInventory wagonInv;
	private StoreInventory storeInv;
	
	/**
	 * Constructor for the StoreController class. Instantiates an inventory controller
	 */
	public StoreController(InventoryController invControl, int quantitySeed){
		wagonInv = invControl.getWagonInventory();
		storeInv = new StoreInventory(quantitySeed);
	}
	
	/**
	 * Uses the inventory controller to buy an item
	 * 
	 * @param item Item type to buy
	 * @param quantity Quantity of items to buy
	 */
	public void buyItem(Item item, int quantity){
		item.setQuantity(-quantity);
		//System.out.println("Quantity to be subtracted from the store: " + -quantity);
		storeInv.add(item);
		item.setQuantity(quantity);
		//System.out.println("Quantity to be added to the wagon: " + quantity);
		wagonInv.add(item);
	}
	
	/**
	 * Uses the inventory controller to sell an item
	 * 
	 * @param item Item type to sell
	 * @param quantity Quantity of items to sell
	 */
	public void sellItem(Item item, int quantity){
		item.setQuantity(-quantity);
		wagonInv.add(item);
		item.setQuantity(quantity);
		storeInv.add(item);
	}
	
	/**
	 * Gets a list of the current items in the wagon
	 * @return List of items in the wagon
	 */
	public WagonInventory getWagonInventory(){
		return wagonInv;
	}
	
	/**
	 * Gets a list of the current items in the store
	 * @return List of items in the store
	 */
	public StoreInventory getStoreInventory(){
		return storeInv;
	}
}
